// 查询列表接口
const getFileList = (params) => {
  return $axios({
    url: '/list/get',
    method: 'post',
    data:{...params}
  })
}

// 创建目录
// 当前位置,目录名,用户名
const mkdirAtCur = (params) => {
  return $axios({
    url: '/list/mkdir',
    method: 'post',
    data:{...params}
  })
}

//下载文件
const download_file_p = (params) => {
  return $axios({
    url: '/list/download',
    method: 'post',
    data:{...params},
    responseType:"blob"
  })
}
//删除文件
const del_file_p = (params) => {
  return $axios({
    url: '/list/del',
    method: 'post',
    data:{...params}
  })
}

// 文件down预览
const commonDownload = (params) => {
  return $axios({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
    },
    url: '/common/download',
    method: 'get',
    params
  })
}

function downloadBlobFile(blobData, fileName) {
  const blob = new Blob([blobData]);
  const downloadElement = document.createElement('a');
  const href = window.URL.createObjectURL(blob);
  downloadElement.href = href;
  downloadElement.download = fileName;
  document.body.appendChild(downloadElement);
  downloadElement.click();
  document.body.removeChild(downloadElement);
  window.URL.revokeObjectURL(href);
}